import request from '@/utils/request'

export function listData(params) {
  return request({
    url: '/user-manager/user-account',
    method: 'get',
    params
  })
}

export function listTypeData(query) {
  return request({
    url: `/user-manager/user-gift-bag${query}`,
    method: 'get'
  })
}

export function putEditData(id, form) {
  return request({
    url: `/user-manager/user-account/${id}`,
    method: 'put',
    data: form
  })
}

export function deleteData(form) {
  return request({
    url: '/user-manager/user-account',
    method: 'delete',
    data: form
  })
}

export function postRecharge(id, form) {
  return request({
    url: `/user-manager/user-account/operate/recharge/${id}`,
    method: 'post',
    data: form
  })
}

export function listGiftData(form) {
  return request({
    url: `/gift/list`,
    method: 'post',
    data: form
  })
}

export function postSendGift(id, form) {
  return request({
    url: `/user-manager/user-account/operate/give-gift/${id}`,
    method: 'post',
    data: form
  })
}

export function postSetBan(id, form) {
  return request({
    url: `/user-manager/user-account/operate/set-ban-user/${id}`,
    method: 'post',
    data: form
  })
}

export function postSetBanNew(id, form) {
  return request({
    url: `/user-manager/user-account/operate/set-ban-user/${id}`,
    method: 'delete',
    data: form
  })
}

export function postSetRoot(id, type) {
  return request({
    url: `/user-manager/user-account/operate/set-user-role/${id}`,
    method: 'post',
    data: { type }
  })
}

export function postReset(id) {
  return request({
    url: `/user-manager/user-account/operate/reset-emchat/${id}`,
    method: 'post'
  })
}

export function postSendExperience(id, form) {
  return request({
    url: `/user-manager/user-account/operate/add-exp/${id}`,
    method: 'post',
    data: form
  })
}

/*
 * @desc: 封禁或者解封用户
 * @params: user_id: string 用户ID
 * @params: freeze_reason: string 封禁原因 冻结账户时必传
 * @return: Promise
 * */
export function toFreezeUser(user_id, freeze_reason) {
  return request({
    url: '/user-manager/user-account/setEarningsStatus',
    method: 'post',
    data: { user_id, freeze_reason }
  })
}

//换绑手机号
export function toPutChangePhone(data) {
  return request({
    url: '/user-manager/user-account/mobile',
    method: 'put',
    data
  })
}

// 用户详情
export function userAccountDetail(params) {
  return request({
    url: '/user-manager/user-account/detail',
    method: 'get',
    params: params
  })
}

// 增加洗练石
export function userBalanceSwap(params) {
  return request({
    url: '/api/pet/user/balance/swap',
    method: 'post',
    data: params
  })
}